/*
 * DeploymentSystem.cpp
 *
 *  Created on: Jan 20, 2011
 *      Author: Joey Vignato
 */

#include "DeploymentSystem.h"
#include "Relay.h"
#include "DigitalInput.h"
#include "Task.h"

DeploymentSystem::DeploymentSystem():
	m_deployRelay(4, 1),
	m_deployedSensor(4, 10)
{
	//m_deploying=false;
	//m_deployed=false;
}

void DeploymentSystem::deploy(){
	//m_deploying = true;
	//Task myTask("deployTask", (FUNCPTR)callDeployTask(this));
	m_deployRelay.Set(Relay::kReverse);	
}


//Function that calls deployTask, since we can't run that function in MyRobot.
 int DeploymentSystem::callDeployTask(void* object){
	DeploymentSystem* dobject = (DeploymentSystem*) object;
	dobject->deployTask();
	
	return 1;
}

//Function that actually runs the deployer to go forward and stop once deployed.
int DeploymentSystem::deployTask(){
	while(m_deployedSensor.Get() == 0){
		m_deployRelay.Set(Relay::kForward);	
	}
	m_deployRelay.Set(Relay::kOff);
	//m_deploying = false;
	//m_deployed = true;
	return 1;
}

//Function that allows the driver to bring the deployer back in.
void DeploymentSystem::retract(){
	m_deployRelay.Set(Relay::kForward);
}

/*bool DeploymentSystem::isDeployed(){
	return m_deployed;
}

bool DeploymentSystem::isDeploying(){
	return m_deploying;
}*/

void DeploymentSystem::stop(){
	m_deployRelay.Set(Relay::kOff);
}




